package database

import "gitee.com/xiaofengfeng123/srv-paper-tape/errors"

func (u User)ExistByUid(uid string)bool{
	has,_ := Engine.Where("uid = ?",uid).Exist(&u)
	return has
}

func UserByUid(uid string)(*User,bool){
	user := new(User)

	b,_ := Engine.Where("uid = ?",uid).Get(user)
	return user,b
}



func UserById(id string)(*User,error){
	user := new(User)

	b,err := Engine.Where("id = ?",id).Get(user)
	if err !=nil{
		return nil,err
	}
	if !b{
		return nil,errors.ErrUserNotFound
	}
	return user,nil
}

